from urllib import error, request
import socket

try:
    response = request.urlopen('http://cuiqingcai.com/index.html')
except error.HTTPError as e:
    print(e.reason, e.code, e.headers, sep='\n')
except error.URLError as e:
    print(e.reason)
else:
    print('Request Successfully!')


#   *************  #

try:
    response = request.urlopen('https://python.org/', timeout=0.1)

except error.URLError as e:
    if  isinstance(e.reason, socket.timeout):
        print('TIME OUT')